// components/home/index.js
const app = getApp();
let that;
Component({
  options: {
    addGlobalClass: true
  },

  /**
   * 组件的属性列表
   */
  properties: {

  },
  /**
   * 组件的初始数据
   */
  data: {
    pageCur:'',
    mainActiveIndex: 0,
    // contentList: [
    //   [ // 分类1对应内容
    //     { id: 110, thumb:'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF', text: '艾斯卡尔' , content: '' , price:'15.00',originalPrice:'120'},
    //     { id: 111,thumb:'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF', text: 'دوۋيىن دەرسلىكى 5 يىللىق', content: 'مۇقىم تەربىيلىنىدۇ',price:'15.00',originalPrice:'120' },
    //     { id: 112,thumb:'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF', text: 'دوۋيىن دەرسلىكى 5 يىللىق', content: 'مۇقىم تەربىيلىنىدۇ', price:'15.00',originalPrice:'120' },
    //     { id: 113,thumb:'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF', text: 'دوۋيىن دەرسلىكى 5 يىللىق', content: 'مۇقىم تەربىيلىنىدۇ', price:'15.00',originalPrice:'120' },
    //     { id: 114, thumb:'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF',text: 'دوۋيىن دەرسلىكى 5 يىللىق', content: 'مۇقىم تەربىيلىنىدۇ', price:'15.00',originalPrice:'120' },
    //     { id: 115, thumb:'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF',text: 'دوۋيىن دەرسلىكى 5 يىللىق', content: 'مۇقىم تەربىيلىنىدۇ', price:'15.00',originalPrice:'120' },
    //     { id: 116, thumb:'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF',text: 'دوۋيىن دەرسلىكى 5 يىللىق',  content: 'مۇقىم تەربىيلىنىدۇ',price:'15.00',originalPrice:'120' },
    //     { id: 117, thumb:'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF',text: 'دوۋيىن دەرسلىكى 5 يىللىق', content: 'مۇقىم تەربىيلىنىدۇ', price:'15.00',originalPrice:'120' },
    //     { id: 118, thumb:'https://t7.baidu.com/it/u=1595072465,3644073269&fm=193&f=GIF',text: 'دوۋيىن دەرسلىكى 5 يىللىق', content: 'مۇقىم تەربىيلىنىدۇ', price:'15.00',originalPrice:'120' }
    //   ],
    //   [ // 分类2对应内容
    //     { id: 200, thumb:'https://t7.baidu.com/it/u=2371362259,3988640650&fm=193&f=GIF',text: 'شىپىنخاۋ 10 يىللىق دەرسلىكى' , content: 'مۇقىم تەربىيلىنىدۇ', price:'15.00',originalPrice:'120'}
    //   ],
    //   [ // 分类3对应内容
    //     { id: 301, thumb:'https://t7.baidu.com/it/u=355704943,1318565630&fm=193&f=GIF',text: 'كۈەيشوۋ 10 يىللىق دەرسلىكى', content: 'مۇقىم تەربىيلىنىدۇ', price:'15.00',originalPrice:'120' },
    //     { id: 302, thumb:'https://t7.baidu.com/it/u=355704943,1318565630&fm=193&f=GIF',text: 'كۈەيشوۋ 5يىللىق دەرسلىكى' , content: 'مۇقىم تەربىيلىنىدۇ', price:'15.00',originalPrice:'120'}
    //   ],
    //   [ // 分类3对应内容
    //     { id: 401, thumb:'https://t7.baidu.com/it/u=1423490396,3473826719&fm=193&f=GIF',text: 'ئەيئاي دەرسلىكى 10 يىللىق ' , content: 'مۇقىم تەربىيلىنىدۇ', price:'15.00',originalPrice:'120'},
    //     { id: 402, thumb:'https://t7.baidu.com/it/u=1423490396,3473826719&fm=193&f=GIF',text: 'ئەيئاي 5 يىللىق دەرسلىكى', content: 'مۇقىم تەربىيلىنىدۇ', price:'15.00',originalPrice:'120' }
    //   ]
    // ],
  
    contentList:[
      {
        avator: "https://qiniu.camino.top/%E5%8F%A4%E5%86%8D%E5%8A%9B%E9%9E%8B%E5%BA%97%E5%A4%B4%E5%83%8F.jpg",
        contentimageurl: "https://qiniu.camino.top/%E5%8F%A4%E5%86%8D%E5%8A%9B%E9%9E%8B%E5%BA%97.jpg",
        id: 1,
        student_id: 1,
        subtitle: "پۈتۈن توردا 200 مىڭدىن جىق پىنتوزىسى بار",
        title: "古再力鞋店"
      },
      {
        avator: "https://qiniu.camino.top/%E5%A6%88%E5%A6%88%E7%9A%84%E5%91%B3%E9%81%93%28%E8%91%A1%E8%90%84%E4%B9%8B%E4%B9%A1%29%E5%A4%B4%E5%83%8F.jpg",
        contentimageurl: "https://qiniu.camino.top/%E5%A6%88%E5%A6%88%E7%9A%84%E5%91%B3%E9%81%93%28%E8%91%A1%E8%90%84%E4%B9%8B%E4%B9%A1%29.jpg",
        id: 2,
        student_id: 2,
        subtitle: "پۈتۈن توردا 200 مىڭغا يېقىن پىنتوزىسى بار",
        title: "妈妈的味道(葡萄之乡)"
      },
      {
        avator: "https://qiniu.camino.top/%E6%96%B0%E7%96%86%E5%84%BF%E5%AD%90%E5%93%87%E5%93%87%E5%A4%B4%E5%83%8F.jpg",
        contentimageurl: "https://qiniu.camino.top/%E6%96%B0%E7%96%86%E5%84%BF%E5%AD%90%E5%93%87%E5%93%87.jpg",
        id: 3,
        student_id: 3,
        subtitle: "پۈتۈن توردا 270مىڭدىن جىق پىنتوزىسى بار",
        title: "新疆儿子哇哇"
      },
      {
        avator: "https://qiniu.camino.top/%E5%B7%B4%E8%BE%BE%E6%9C%A8%E5%AE%B6%E6%97%8F%28badam%29%E5%A4%B4%E5%83%8F.jpg",
        contentimageurl: "https://qiniu.camino.top/%E5%B7%B4%E8%BE%BE%E6%9C%A8%E5%AE%B6%E6%97%8F%28badam%29.jpg",
        id: 4,
        student_id: 4,
        subtitle: "پۈتۈن توردا 60مىڭدىن جىق پىنتوزىسى بار",
        title: "巴达木家族(badam)"
      },
       {
        avator: "https://qiniu.camino.top/%23%E6%B3%95%E7%89%B9%E5%A4%B4%E5%83%8F.jpg",
        contentimageurl: "https://qiniu.camino.top/%23%E6%B3%95%E7%89%B9.jpg",
        id: 5,
        student_id: 5,
        subtitle: "پۈتۈن توردا 30 مىڭدىن جىق پىنتوزىسى بار",
        title: "#法特"
      },
      {
        
          avator: "https://qiniu.camino.top/%E5%92%8C%E7%94%B0%E5%85%84%E5%BC%9F%E5%A4%B4%E5%83%8F.jpg",
          contentimageurl: "https://qiniu.camino.top/%E5%92%8C%E7%94%B0%E5%85%84%E5%BC%9F.jpg",
          id: 6,
          student_id: 6,
          subtitle: "پۈتۈن توردا 150مىڭغا يېقىن پىنتوزىسى بار",
          title: "和田兄弟"
        
      },
    ]
  },

  /**
   * 组件的方法列表
   */
  attached() {
    that = this;
  },

  methods: {
    componentInnerFunction(e) {
      // this.requestApi()
      that.setData({
        pageCur: e,
      })
    },
    requestApi()
    {
      const that = this;
      wx.request({
        url: 'http://127.0.0.1:8000/students/',
        header: {
          'content-type': 'application/json' // 默认值
        },
        success (res) {
          console.log('innerdata===',res.data)
          that.setData({
            contentList :res.data
          });
  
     
        },  
        fail: (err) => {
          console.error('请求失败:', err);
        }
        
     
      })

    },

    onClickItem(event) {
      // 从 event.currentTarget.dataset 获取 data-id 和 data-item
      const { id, item } = event.currentTarget.dataset;
      console.log('点击的ID:', id);      // 输出 data-id 的值
      console.log('点击的Item:', item);  // 输出 data-item 的值
      wx.navigateTo({
        // url: '/pages/studentDetail/studentDetail?item='+item, // 假设路径为 /pages/student/studentDetail/
        url: `/pages/studentDetail/studentDetail?item=${encodeURIComponent(JSON.stringify(item))}`,
        fail(err) {
          console.error('跳转失败:', err);
        }
      });
     
      
      // 示例：设置 activeId 为点击的 id
      
    }
  }
})